package com.example;

import com.example.Thread.JudgeThread;
import com.example.event.DAO.EventDAO;
import com.example.history.DAO.HistoryDAO;
import com.example.historyHour.DAO.HistoryHourDAO;
import com.example.mytest.DAO.MessageDAO;
import com.example.mytest.DAO.DeviceDAO;
import com.example.mytest.DAO.DeviceOnlineRecordDAO;
import com.example.service.HandleOnline;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import redis.clients.jedis.JedisPool;

@SpringBootApplication
public class DemoApplication implements CommandLineRunner {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

	@Autowired
	private JedisPool jedisPool;

	@Autowired
	private DeviceDAO deviceDAO;

	@Autowired
	private HistoryDAO historyDAO;

	@Autowired
	private DeviceOnlineRecordDAO deviceOnlineRecordDAO;


	@Autowired
	private EventDAO eventDAO;

	@Autowired
	private HistoryHourDAO historyHourDAO;

	@Autowired
	private MessageDAO messageDAO;

	@Override
	public void run(String... strings) throws Exception{
		final HandleOnline handle;

		handle = new HandleOnline(deviceDAO,historyDAO,deviceOnlineRecordDAO,eventDAO,historyHourDAO, messageDAO);

		JudgeThread judgeThread = new JudgeThread(jedisPool,handle);
		judgeThread.start();
	}

}
